import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
import vuexPersist from "vuex-persist";
export default new Vuex.Store({
  state: {
    historyData: []
  },
  mutations: {
    addHistory(state, val) {
      state.historyData.push(val)
    },
    remove(state, i) {
      state.historyData.splice(i, 1)
    },
    clear(state) {
      let obj = confirm('你确认要清空历史记录吗')
      if (obj) {
        state.historyData = []
      }
    }
  },
  actions: {},
  modules: {},
  plugins: [
    new vuexPersist({
      storage: window.localStorage,
    }).plugin,
  ],
})